package com.example.oasystem.service.impl;

import com.example.oasystem.dao.attachment.AoaAttachmentListDaoOfl;
import com.example.oasystem.dao.plan.AoaPlanListDao;
import com.example.oasystem.entity.attachment.AoaAttachmentListOfl;
import com.example.oasystem.entity.dept.AoaDept;
import com.example.oasystem.entity.plan.AoaPlanList;
import com.example.oasystem.entity.status.AoaStatusList;
import com.example.oasystem.entity.type.AoaTypeList;
import com.example.oasystem.service.AoaPlanListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AoaPlanListServiceImpl implements AoaPlanListService {

    @Autowired
    AoaPlanListDao aoaPlanListDao;

    @Autowired
    AoaAttachmentListDaoOfl aoaAttachmentListDaoOfl;

    @Override
    public PageInfo<AoaPlanList> plans(Long planUserId, String baseKey, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<AoaPlanList> aoaPlanLists = aoaPlanListDao.plans(planUserId, baseKey);
        PageInfo<AoaPlanList>pageInfo=new PageInfo<>(aoaPlanLists);
        return pageInfo;
    }

    @Override
    public PageInfo<AoaPlanList> myPlans(Long planUserId, String baseKey, Integer type, Integer time, Integer status, int pageNum, int pageSize) {
        System.out.println("impl里stuats"+status);
        PageHelper.startPage(pageNum,pageSize);
        String order="desc";
        if(type!=null&&type==1)
        {
            order="asc";
        }
        if(time!=null&&time==1)
        {
            order="asc";
        }
        if(status!=null&&status==1)
        {
            order="asc";
        }
        System.out.println("这里是");
        List<AoaPlanList> aoaPlanLists = aoaPlanListDao.myPlans(planUserId,baseKey,type,time,status, order);
        PageInfo<AoaPlanList> pageInfo = new PageInfo<>(aoaPlanLists);
        return pageInfo;
    }

    @Override
    public AoaDept dept(Long deptId) {
        return aoaPlanListDao.dept(deptId);
    }

    @Override
    public List<AoaTypeList> typeList() {
        return aoaPlanListDao.typeList();
    }

    @Override
    public List<AoaStatusList> statusList() {
        return aoaPlanListDao.statusList();
    }

    @Override
    public int deleteByPrimaryKey(Long planId) {
        return aoaPlanListDao.deleteByPrimaryKey(planId);
    }

    @Override
    public int insertSelective(AoaPlanList record) {
        return aoaPlanListDao.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(AoaPlanList record) {
        return aoaPlanListDao.updateByPrimaryKeySelective(record);
    }

    @Override
    public AoaPlanList selectByPrimaryKey(Long planId) {
        return aoaPlanListDao.selectByPrimaryKey(planId);
    }

    @Override
    public int insertSelectivePath(AoaAttachmentListOfl record) {
        return aoaAttachmentListDaoOfl.insertSelective(record);
    }

    @Override
    public List<AoaAttachmentListOfl> attachment() {
        return aoaAttachmentListDaoOfl.attachment();
    }
}
